<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>蓝旭第三次作业1</title>
</head>

<body>
    <script>
        var arr1 = [4, 0, 7, 9, 0, 0, 2, 6, 0, 3, 1, 0];
        var arr2 = [];
        for (var i = 0; i < 12; i++) {
            if (arr1[i] != 0) {
                arr2[arr2.length] = arr1[i];
            }
        }
        console.log(arr2);
    </script>
</body>

</html>